package com.sucisoft.base.imageloder.config;

import android.content.Context;
import android.widget.ImageView;

import com.sucisoft.base.R;


/**
 * 2033152950
 * Created by zf on 2018/1/2.
 */

public class ImgC<T extends Context> {

    private Object Url = null;

    private int errorImage = R.mipmap.ic_image_error;

    private T t;

    private ImageView imageView = null;

    //内存缓存
    private boolean skipMemoryCache = true;
    //磁盘缓存
    private boolean DiskCacheStrategy = true;

    public ImgC<T> setUrl(Object url) {
        Url = url;
        return this;
    }

    /**
     *  设置加载失败图片
     * @param errorImage
     * @return
     */
    public ImgC setErrorImage(int errorImage) {
        this.errorImage = errorImage;
        return this;
    }

    /**
     *  设置控件 类型为ImageView
     * @param imageView
     * @return
     */
    public ImgC setImageView(ImageView imageView) {
        this.imageView = imageView;
        return this;
    }

    /**
     * 设置跳过内存缓存
     * true 跳过  false进行内存缓存
     * @param skipMemoryCache
     * @return
     */
    public ImgC setSkipMemoryCache(boolean skipMemoryCache) {
        this.skipMemoryCache = skipMemoryCache;
        return this;
    }

    /**
     *设置磁盘缓存策略  true 不进行磁盘缓存  false 缓存截切以后的
     * @param diskCacheStrategy
     * @return
     */
    public ImgC setDiskCacheStrategy(boolean diskCacheStrategy) {
        DiskCacheStrategy = diskCacheStrategy;
        return this;
    }

    private ImgC() {
    }

    protected ImgC(T t) {
        this.t = t;
    }

    /**
     * new
     * @param t
     * @param <T>
     * @return
     */
    public static <T extends Context> ImgC newC(T t) {
        return new ImgC<T>(t);
    }

    public Object getUrl() {
        return Url;
    }

    public int getErrorImage() {
        return errorImage;
    }

    public T getT() {
        return t;
    }

    public ImageView getImageView() {
        return imageView;
    }

    public boolean isSkipMemoryCache() {
        return skipMemoryCache;
    }

    public boolean isDiskCacheStrategy() {
        return DiskCacheStrategy;
    }

}
